#!/bin/bash
PATH="/opt/java/jdk1.8.0_151/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"
echo "======================to do transform=========================="
cd docker-hive
echo "transform in background"
docker-compose exec -d hive-server env LANG=C.UTF-8 bash -c '/opt/hive/bin/beeline -u jdbc:hive2://localhost:10000 -e "insert overwrite table ads_wms.goods_sells_info
select g.goods_id goods_id,
g.goods_name goods_name,
nvl(ro.out_count, 0) out_count
from ods_wms.goods g left join (select goods_id,
sum(out_count) out_count
from ods_wms.record_out
where out_time >= add_months(from_utc_timestamp(CURRENT_TIMESTAMP,'GMT+8') , -1)
group by goods_id) ro
on g.goods_id = ro.goods_id;"'
